project(
  'sqlpp11',
  'cpp',
  version: '0.64',
  license: 'BSD-2-Clause',
)

meson.override_find_program('ddl2cpp', files('scripts/ddl2cpp'))

connector_deps = []

date_dep = dependency(
  'hinnant-date',
  fallback: ['hinnant-date', 'date_dep'],
)

sqlpp11_postgresql_header_files = files()
if get_option('postgresql_connector')
  connector_deps += [
    dependency(
      'libpq',
      required: true,
    ),
  ]
  sqlpp11_postgresql_header_files = files(
    'include/sqlpp11/postgresql/bind_result.h',
    'include/sqlpp11/postgresql/connection.h',
    'include/sqlpp11/postgresql/connection_config.h',
    'include/sqlpp11/postgresql/detail/connection_handle.h',
    'include/sqlpp11/postgresql/detail/prepared_statement_handle.h',
    'include/sqlpp11/postgresql/dynamic_libpq.h',
    'include/sqlpp11/postgresql/exception.h',
    'include/sqlpp11/postgresql/insert.h',
    'include/sqlpp11/postgresql/on_conflict.h',
    'include/sqlpp11/postgresql/on_conflict_do_nothing.h',
    'include/sqlpp11/postgresql/on_conflict_do_update.h',
    'include/sqlpp11/postgresql/postgresql.h',
    'include/sqlpp11/postgresql/prepared_statement.h',
    'include/sqlpp11/postgresql/result.h',
    'include/sqlpp11/postgresql/result_field.h',
    'include/sqlpp11/postgresql/returning.h',
    'include/sqlpp11/postgresql/returning_column_list.h',
    'include/sqlpp11/postgresql/serializer.h',
    'include/sqlpp11/postgresql/update.h',
    'include/sqlpp11/postgresql/visibility.h',
  )
endif

sqlpp11_sqlite3_header_files = files()
if get_option('sqlite3_connector') or get_option('sqlcipher_connector')
  if get_option('sqlite3_connector')
    connector_deps += [
      dependency(
        'sqlite3',
        fallback: ['sqlite3'],
        required: true,
      ),
    ]
  endif
  if get_option('sqlcipher_connector')
    connector_deps += [
      dependency(
        'sqlcipher',
        required: true,
      ),
    ]
  endif
  sqlpp11_sqlite3_header_files = files(
    'include/sqlpp11/sqlite3/bind_result.h',
    'include/sqlpp11/sqlite3/connection.h',
    'include/sqlpp11/sqlite3/connection_config.h',
    'include/sqlpp11/sqlite3/detail/connection_handle.h',
    'include/sqlpp11/sqlite3/detail/prepared_statement_handle.h',
    'include/sqlpp11/sqlite3/dynamic_libsqlite3.h',
    'include/sqlpp11/sqlite3/export.h',
    'include/sqlpp11/sqlite3/insert_or.h',
    'include/sqlpp11/sqlite3/prepared_statement.h',
    'include/sqlpp11/sqlite3/serializer.h',
    'include/sqlpp11/sqlite3/sqlite3.h',
  )
endif

sqlpp11_mysql_header_files = files()
if get_option('mysql_connector') or get_option('mariadb_connector')
  if get_option('mysql_connector')
    connector_deps += [
      dependency(
        'mysqlclient',
        required: true,
      ),
    ]
  endif
  if get_option('mariadb_connector')
    connector_deps += [
      dependency(
        'libmariadb',
        required: true,
      ),
    ]
  endif
  sqlpp11_mysql_header_files = files(
    'include/sqlpp11/mysql/bind_result.h',
    'include/sqlpp11/mysql/char_result.h',
    'include/sqlpp11/mysql/char_result_row.h',
    'include/sqlpp11/mysql/connection.h',
    'include/sqlpp11/mysql/connection_config.h',
    'include/sqlpp11/mysql/connection_pool.h',
    'include/sqlpp11/mysql/detail/connection_handle.h',
    'include/sqlpp11/mysql/detail/prepared_statement_handle.h',
    'include/sqlpp11/mysql/detail/result_handle.h',
    'include/sqlpp11/mysql/mysql.h',
    'include/sqlpp11/mysql/prepared_statement.h',
    'include/sqlpp11/mysql/remove.h',
    'include/sqlpp11/mysql/serializer.h',
    'include/sqlpp11/mysql/sqlpp_mysql.h',
    'include/sqlpp11/mysql/update.h',
  )
endif

sqlpp11_header_files = files(
  'include/sqlpp11/aggregate_function_operators.h',
  'include/sqlpp11/aggregate_functions.h',
  'include/sqlpp11/aggregate_functions/avg.h',
  'include/sqlpp11/aggregate_functions/count.h',
  'include/sqlpp11/aggregate_functions/max.h',
  'include/sqlpp11/aggregate_functions/min.h',
  'include/sqlpp11/aggregate_functions/sum.h',
  'include/sqlpp11/alias.h',
  'include/sqlpp11/alias_operators.h',
  'include/sqlpp11/alias_provider.h',
  'include/sqlpp11/all_of.h',
  'include/sqlpp11/any.h',
  'include/sqlpp11/assignment.h',
  'include/sqlpp11/auto_alias.h',
  'include/sqlpp11/bad_expression.h',
  'include/sqlpp11/basic_expression_operators.h',
  'include/sqlpp11/boolean_expression.h',
  'include/sqlpp11/case.h',
  'include/sqlpp11/char_sequence.h',
  'include/sqlpp11/chrono.h',
  'include/sqlpp11/column.h',
  'include/sqlpp11/column_fwd.h',
  'include/sqlpp11/column_types.h',
  'include/sqlpp11/compat/make_unique.h',
  'include/sqlpp11/connection.h',
  'include/sqlpp11/connection_pool.h',
  'include/sqlpp11/consistent.h',
  'include/sqlpp11/cte.h',
  'include/sqlpp11/custom_query.h',
  'include/sqlpp11/data_types.h',
  'include/sqlpp11/data_types/blob.h',
  'include/sqlpp11/data_types/blob/column_operators.h',
  'include/sqlpp11/data_types/blob/data_type.h',
  'include/sqlpp11/data_types/blob/expression_operators.h',
  'include/sqlpp11/data_types/blob/operand.h',
  'include/sqlpp11/data_types/blob/parameter_value.h',
  'include/sqlpp11/data_types/blob/result_field.h',
  'include/sqlpp11/data_types/blob/wrap_operand.h',
  'include/sqlpp11/data_types/boolean.h',
  'include/sqlpp11/data_types/boolean/column_operators.h',
  'include/sqlpp11/data_types/boolean/data_type.h',
  'include/sqlpp11/data_types/boolean/expression_operators.h',
  'include/sqlpp11/data_types/boolean/operand.h',
  'include/sqlpp11/data_types/boolean/parameter_value.h',
  'include/sqlpp11/data_types/boolean/result_field.h',
  'include/sqlpp11/data_types/boolean/wrap_operand.h',
  'include/sqlpp11/data_types/column_operators.h',
  'include/sqlpp11/data_types/day_point.h',
  'include/sqlpp11/data_types/day_point/column_operators.h',
  'include/sqlpp11/data_types/day_point/data_type.h',
  'include/sqlpp11/data_types/day_point/expression_operators.h',
  'include/sqlpp11/data_types/day_point/operand.h',
  'include/sqlpp11/data_types/day_point/parameter_value.h',
  'include/sqlpp11/data_types/day_point/result_field.h',
  'include/sqlpp11/data_types/day_point/wrap_operand.h',
  'include/sqlpp11/data_types/floating_point.h',
  'include/sqlpp11/data_types/floating_point/column_operators.h',
  'include/sqlpp11/data_types/floating_point/data_type.h',
  'include/sqlpp11/data_types/floating_point/expression_operators.h',
  'include/sqlpp11/data_types/floating_point/operand.h',
  'include/sqlpp11/data_types/floating_point/parameter_value.h',
  'include/sqlpp11/data_types/floating_point/result_field.h',
  'include/sqlpp11/data_types/floating_point/wrap_operand.h',
  'include/sqlpp11/data_types/integral.h',
  'include/sqlpp11/data_types/integral/column_operators.h',
  'include/sqlpp11/data_types/integral/data_type.h',
  'include/sqlpp11/data_types/integral/expression_operators.h',
  'include/sqlpp11/data_types/integral/operand.h',
  'include/sqlpp11/data_types/integral/parameter_value.h',
  'include/sqlpp11/data_types/integral/result_field.h',
  'include/sqlpp11/data_types/integral/wrap_operand.h',
  'include/sqlpp11/data_types/no_value.h',
  'include/sqlpp11/data_types/no_value/column_operators.h',
  'include/sqlpp11/data_types/no_value/data_type.h',
  'include/sqlpp11/data_types/no_value/expression_operators.h',
  'include/sqlpp11/data_types/no_value/operand.h',
  'include/sqlpp11/data_types/no_value/parameter_value.h',
  'include/sqlpp11/data_types/no_value/result_field.h',
  'include/sqlpp11/data_types/no_value/wrap_operand.h',
  'include/sqlpp11/data_types/parameter_value.h',
  'include/sqlpp11/data_types/parameter_value_base.h',
  'include/sqlpp11/data_types/text.h',
  'include/sqlpp11/data_types/text/column_operators.h',
  'include/sqlpp11/data_types/text/concat.h',
  'include/sqlpp11/data_types/text/data_type.h',
  'include/sqlpp11/data_types/text/expression_operators.h',
  'include/sqlpp11/data_types/text/like.h',
  'include/sqlpp11/data_types/text/operand.h',
  'include/sqlpp11/data_types/text/parameter_value.h',
  'include/sqlpp11/data_types/text/result_field.h',
  'include/sqlpp11/data_types/text/return_type_like.h',
  'include/sqlpp11/data_types/text/wrap_operand.h',
  'include/sqlpp11/data_types/time_of_day.h',
  'include/sqlpp11/data_types/time_of_day/column_operators.h',
  'include/sqlpp11/data_types/time_of_day/data_type.h',
  'include/sqlpp11/data_types/time_of_day/expression_operators.h',
  'include/sqlpp11/data_types/time_of_day/operand.h',
  'include/sqlpp11/data_types/time_of_day/parameter_value.h',
  'include/sqlpp11/data_types/time_of_day/result_field.h',
  'include/sqlpp11/data_types/time_of_day/wrap_operand.h',
  'include/sqlpp11/data_types/time_point.h',
  'include/sqlpp11/data_types/time_point/column_operators.h',
  'include/sqlpp11/data_types/time_point/data_type.h',
  'include/sqlpp11/data_types/time_point/expression_operators.h',
  'include/sqlpp11/data_types/time_point/operand.h',
  'include/sqlpp11/data_types/time_point/parameter_value.h',
  'include/sqlpp11/data_types/time_point/result_field.h',
  'include/sqlpp11/data_types/time_point/wrap_operand.h',
  'include/sqlpp11/data_types/unsigned_integral.h',
  'include/sqlpp11/data_types/unsigned_integral/column_operators.h',
  'include/sqlpp11/data_types/unsigned_integral/data_type.h',
  'include/sqlpp11/data_types/unsigned_integral/expression_operators.h',
  'include/sqlpp11/data_types/unsigned_integral/operand.h',
  'include/sqlpp11/data_types/unsigned_integral/parameter_value.h',
  'include/sqlpp11/data_types/unsigned_integral/result_field.h',
  'include/sqlpp11/data_types/unsigned_integral/wrap_operand.h',
  'include/sqlpp11/default_value.h',
  'include/sqlpp11/detail/column_tuple_merge.h',
  'include/sqlpp11/detail/enable_if.h',
  'include/sqlpp11/detail/float_safe_ostringstream.h',
  'include/sqlpp11/detail/get_first.h',
  'include/sqlpp11/detail/get_last.h',
  'include/sqlpp11/detail/index_sequence.h',
  'include/sqlpp11/detail/pick_arg.h',
  'include/sqlpp11/detail/type_set.h',
  'include/sqlpp11/detail/type_vector.h',
  'include/sqlpp11/detail/void.h',
  'include/sqlpp11/dynamic_join.h',
  'include/sqlpp11/dynamic_pre_join.h',
  'include/sqlpp11/dynamic_select_column_list.h',
  'include/sqlpp11/eval.h',
  'include/sqlpp11/exception.h',
  'include/sqlpp11/exists.h',
  'include/sqlpp11/expression.h',
  'include/sqlpp11/expression_fwd.h',
  'include/sqlpp11/expression_operators.h',
  'include/sqlpp11/expression_return_types.h',
  'include/sqlpp11/field_spec.h',
  'include/sqlpp11/for_update.h',
  'include/sqlpp11/from.h',
  'include/sqlpp11/functions.h',
  'include/sqlpp11/group_by.h',
  'include/sqlpp11/having.h',
  'include/sqlpp11/hidden.h',
  'include/sqlpp11/in.h',
  'include/sqlpp11/in_fwd.h',
  'include/sqlpp11/inconsistent.h',
  'include/sqlpp11/insert.h',
  'include/sqlpp11/insert_value.h',
  'include/sqlpp11/insert_value_list.h',
  'include/sqlpp11/interpret_tuple.h',
  'include/sqlpp11/interpretable.h',
  'include/sqlpp11/interpretable_list.h',
  'include/sqlpp11/into.h',
  'include/sqlpp11/is_equal_to_or_null.h',
  'include/sqlpp11/is_not_null.h',
  'include/sqlpp11/is_null.h',
  'include/sqlpp11/is_null_fwd.h',
  'include/sqlpp11/join.h',
  'include/sqlpp11/join_types.h',
  'include/sqlpp11/limit.h',
  'include/sqlpp11/logic.h',
  'include/sqlpp11/lower.h',
  'include/sqlpp11/named_interpretable.h',
  'include/sqlpp11/no_data.h',
  'include/sqlpp11/no_name.h',
  'include/sqlpp11/noop.h',
  'include/sqlpp11/noop_fwd.h',
  'include/sqlpp11/not_in.h',
  'include/sqlpp11/null.h',
  'include/sqlpp11/offset.h',
  'include/sqlpp11/on.h',
  'include/sqlpp11/operand_check.h',
  'include/sqlpp11/order_by.h',
  'include/sqlpp11/over.h',
  'include/sqlpp11/parameter.h',
  'include/sqlpp11/parameter_list.h',
  'include/sqlpp11/parameterized_verbatim.h',
  'include/sqlpp11/policy_update.h',
  'include/sqlpp11/portable_static_assert.h',
  'include/sqlpp11/ppgen.h',
  'include/sqlpp11/ppgen/colops/auto_increment.h',
  'include/sqlpp11/ppgen/colops/blob.h',
  'include/sqlpp11/ppgen/colops/bool.h',
  'include/sqlpp11/ppgen/colops/comment.h',
  'include/sqlpp11/ppgen/colops/datetime.h',
  'include/sqlpp11/ppgen/colops/default.h',
  'include/sqlpp11/ppgen/colops/floating_point.h',
  'include/sqlpp11/ppgen/colops/foreign_key.h',
  'include/sqlpp11/ppgen/colops/index.h',
  'include/sqlpp11/ppgen/colops/integer.h',
  'include/sqlpp11/ppgen/colops/not_null.h',
  'include/sqlpp11/ppgen/colops/null.h',
  'include/sqlpp11/ppgen/colops/primary_key.h',
  'include/sqlpp11/ppgen/colops/text.h',
  'include/sqlpp11/ppgen/colops/timestamp.h',
  'include/sqlpp11/ppgen/colops/unique_index.h',
  'include/sqlpp11/ppgen/colops/unsigned_integer.h',
  'include/sqlpp11/ppgen/colops/varchar.h',
  'include/sqlpp11/ppgen/tblops/character_set.h',
  'include/sqlpp11/ppgen/tblops/comment.h',
  'include/sqlpp11/ppgen/tblops/default.h',
  'include/sqlpp11/ppgen/tblops/engine.h',
  'include/sqlpp11/ppgen/tools/tuple_pop_front.h',
  'include/sqlpp11/ppgen/tools/wrap_seq.h',
  'include/sqlpp11/pre_join.h',
  'include/sqlpp11/prepared_execute.h',
  'include/sqlpp11/prepared_insert.h',
  'include/sqlpp11/prepared_remove.h',
  'include/sqlpp11/prepared_select.h',
  'include/sqlpp11/prepared_update.h',
  'include/sqlpp11/remove.h',
  'include/sqlpp11/result.h',
  'include/sqlpp11/result_field.h',
  'include/sqlpp11/result_field_base.h',
  'include/sqlpp11/result_row.h',
  'include/sqlpp11/result_row_fwd.h',
  'include/sqlpp11/schema.h',
  'include/sqlpp11/schema_qualified_table.h',
  'include/sqlpp11/select.h',
  'include/sqlpp11/select_column_list.h',
  'include/sqlpp11/select_flag_list.h',
  'include/sqlpp11/select_flags.h',
  'include/sqlpp11/select_pseudo_table.h',
  'include/sqlpp11/serialize.h',
  'include/sqlpp11/serializer_context.h',
  'include/sqlpp11/simple_column.h',
  'include/sqlpp11/single_table.h',
  'include/sqlpp11/some.h',
  'include/sqlpp11/sort_order.h',
  'include/sqlpp11/sqlpp11.h',
  'include/sqlpp11/statement.h',
  'include/sqlpp11/statement_fwd.h',
  'include/sqlpp11/table.h',
  'include/sqlpp11/table_alias.h',
  'include/sqlpp11/table_ref.h',
  'include/sqlpp11/transaction.h',
  'include/sqlpp11/trim.h',
  'include/sqlpp11/type_traits.h',
  'include/sqlpp11/unconditional.h',
  'include/sqlpp11/union.h',
  'include/sqlpp11/union_data.h',
  'include/sqlpp11/union_flags.h',
  'include/sqlpp11/update.h',
  'include/sqlpp11/update_list.h',
  'include/sqlpp11/upper.h',
  'include/sqlpp11/using.h',
  'include/sqlpp11/value.h',
  'include/sqlpp11/value_or_null.h',
  'include/sqlpp11/value_type.h',
  'include/sqlpp11/value_type_fwd.h',
  'include/sqlpp11/verbatim.h',
  'include/sqlpp11/verbatim_table.h',
  'include/sqlpp11/where.h',
  'include/sqlpp11/with.h',
  'include/sqlpp11/without_table_check.h',
  'include/sqlpp11/wrap_operand.h',
  'include/sqlpp11/wrong.h',
)

install_headers(
  sqlpp11_header_files,
  sqlpp11_sqlite3_header_files,
  sqlpp11_mysql_header_files,
  sqlpp11_postgresql_header_files,
)

pkgc = import('pkgconfig')
pkgc.generate(
  name: 'sqlpp11',
  version: meson.project_version(),
  description: 'A type safe SQL template library for C++',
)

sqlpp11_dep = declare_dependency(
  include_directories: include_directories('include'),
  dependencies: [date_dep, connector_deps],
)
